﻿<%@ Application Language="C#" %>

<script runat="server">

    void Application_BeginRequest(object sender, EventArgs e)
    {
        UrlRewritingNet.Web.RegExRewriteRule ruleTinTucCon = new UrlRewritingNet.Web.RegExRewriteRule();
        ruleTinTucCon.VirtualUrl = "^~/TinTuc/(.*)_(.*).html";
        ruleTinTucCon.DestinationUrl = "~/ChiTietTinTuc.aspx?id=$2";
        ruleTinTucCon.IgnoreCase = true;
        ruleTinTucCon.Rewrite = UrlRewritingNet.Web.RewriteOption.Application;
        ruleTinTucCon.Redirect = UrlRewritingNet.Web.RedirectOption.None;
        ruleTinTucCon.RewriteUrlParameter = UrlRewritingNet.Web.RewriteUrlParameterOption.ExcludeFromClientQueryString;
        UrlRewritingNet.Web.UrlRewriting.AddRewriteRule("ruleTinTucCon", ruleTinTucCon);

        UrlRewritingNet.Web.RegExRewriteRule ruleTinTuc = new UrlRewritingNet.Web.RegExRewriteRule();
        ruleTinTuc.VirtualUrl = "^~/TinTuc.html";
        ruleTinTuc.DestinationUrl = "~/DanhSachTinTuc.aspx";
        ruleTinTuc.IgnoreCase = true;
        ruleTinTuc.Rewrite = UrlRewritingNet.Web.RewriteOption.Application;
        ruleTinTuc.Redirect = UrlRewritingNet.Web.RedirectOption.None;
        ruleTinTuc.RewriteUrlParameter = UrlRewritingNet.Web.RewriteUrlParameterOption.ExcludeFromClientQueryString;
        UrlRewritingNet.Web.UrlRewriting.AddRewriteRule("ruleTinTuc", ruleTinTuc);

                
        UrlRewritingNet.Web.RegExRewriteRule ruleSanPham = new UrlRewritingNet.Web.RegExRewriteRule();
        ruleSanPham.VirtualUrl = "^~/(.*)/(.*)_(.*)/(.*)_(.*).html";
        ruleSanPham.DestinationUrl = "~/Detail.aspx?id=$5&loaisanpham=$3";
        ruleSanPham.IgnoreCase = true;
        ruleSanPham.Rewrite = UrlRewritingNet.Web.RewriteOption.Application;
        ruleSanPham.Redirect = UrlRewritingNet.Web.RedirectOption.None;
        ruleSanPham.RewriteUrlParameter = UrlRewritingNet.Web.RewriteUrlParameterOption.ExcludeFromClientQueryString;
        UrlRewritingNet.Web.UrlRewriting.AddRewriteRule("RuleSanPham", ruleSanPham);

        UrlRewritingNet.Web.RegExRewriteRule ruleLoaiSanPhamCon = new UrlRewritingNet.Web.RegExRewriteRule();
        ruleLoaiSanPhamCon.VirtualUrl = "^~/(.*)/(.*)_(.*).html";
        ruleLoaiSanPhamCon.DestinationUrl = "~/ListItem.aspx?type=con&id=$3";
        ruleLoaiSanPhamCon.IgnoreCase = true;
        ruleLoaiSanPhamCon.Rewrite = UrlRewritingNet.Web.RewriteOption.Application;
        ruleLoaiSanPhamCon.Redirect = UrlRewritingNet.Web.RedirectOption.None;
        ruleLoaiSanPhamCon.RewriteUrlParameter = UrlRewritingNet.Web.RewriteUrlParameterOption.ExcludeFromClientQueryString;
        UrlRewritingNet.Web.UrlRewriting.AddRewriteRule("ruleLoaiSanPhamCon", ruleLoaiSanPhamCon);
        
        UrlRewritingNet.Web.RegExRewriteRule ruleLoaiSanPhamCha = new UrlRewritingNet.Web.RegExRewriteRule();
        ruleLoaiSanPhamCon.VirtualUrl = "^~/(.*)_(.*).html";
        ruleLoaiSanPhamCon.DestinationUrl = "~/ListItem.aspx?type=cha&id=$2";
        ruleLoaiSanPhamCon.IgnoreCase = true;
        ruleLoaiSanPhamCon.Rewrite = UrlRewritingNet.Web.RewriteOption.Application;
        ruleLoaiSanPhamCon.Redirect = UrlRewritingNet.Web.RedirectOption.None;
        ruleLoaiSanPhamCon.RewriteUrlParameter = UrlRewritingNet.Web.RewriteUrlParameterOption.ExcludeFromClientQueryString;
        UrlRewritingNet.Web.UrlRewriting.AddRewriteRule("ruleLoaiSanPhamCon", ruleLoaiSanPhamCon);
        
        

    }
    void Application_Start(object sender, EventArgs e) 
    {
    }
    
    void Application_End(object sender, EventArgs e) 
    {
        //  Code that runs on application shutdown

    }
        
    void Application_Error(object sender, EventArgs e) 
    { 
        // Code that runs when an unhandled error occurs

    }

    void Session_Start(object sender, EventArgs e) 
    {
        // Code that runs when a new session is started

    }

    void Session_End(object sender, EventArgs e) 
    {
        // Code that runs when a session ends. 
        // Note: The Session_End event is raised only when the sessionstate mode
        // is set to InProc in the Web.config file. If session mode is set to StateServer 
        // or SQLServer, the event is not raised.

    }
       
</script>
